package com.leo.filter;

import javax.annotation.Resource;

import org.apache.struts2.ServletActionContext;

import com.leo.business.UserBusiness;
import com.leo.util.JsonUtil;
import com.leo.vo.NetBugResult;
import com.opensymphony.xwork2.ActionInvocation;
import com.opensymphony.xwork2.interceptor.MethodFilterInterceptor;

public class AccessTokenInterceptor extends MethodFilterInterceptor {

	private static final long serialVersionUID = -782706110048048600L;

	@Resource
	UserBusiness userBusiness;
	@Override
	protected String doIntercept(ActionInvocation invocation) throws Exception {
		if (!userBusiness.validateAccessToken(ServletActionContext.getRequest().getParameter("accessToken"))) {
			JsonUtil.output(NetBugResult.accessTokenError());
			//System.out.println("accessToken denied");    
			return null;
		}
		return invocation.invoke();
	}
}
